package com.example.springbootproject.mianshi.proxy;

import com.example.springbootproject.mianshi.proxy.MyProxy;
import com.example.springbootproject.mianshi.proxy.UserDao;
import com.example.springbootproject.mianshi.proxy.UserDaoImpl;

import java.lang.reflect.Proxy;

public class Test {

    // 测试代理
    public static void main(String[] args) {
        Class[] clazz = {UserDao.class};
        UserDaoImpl userDao = new UserDaoImpl();
        UserDao o  = (UserDao) Proxy.newProxyInstance(MyProxy.class.getClassLoader(), clazz, new MyProxy(userDao));
        int res = o.add(1,2);
        System.out.println("result = " + res);
    }
}
